
import { staticRoutes } from '@/router'
import { resetRouter } from '@/router';

export default {
    namespaced: true,
    state() {
        return {
            // 菜单数据局
            menuList: [...staticRoutes]
        }
    },
    mutations: {
        resetMenu(state) {
            // 重置菜单
            state.menuList = [...staticRoutes]
            // 重置路由(清除之前通过 addRoute动态添加路由规则)
            resetRouter()
        },
        setMenuList(state, filterRoutes) {
            // 将用户的权限菜单数据和静态路由进行拼接，形成完成的菜单数据
            state.menuList = [...staticRoutes, ...filterRoutes]
        }
    }
}